package cn.wolfcode.crm.service.impl;

import cn.wolfcode.crm.domain.SafetyMechanism;
import cn.wolfcode.crm.mapper.SafetyMechanismMapper;
import cn.wolfcode.crm.page.PageResult;
import cn.wolfcode.crm.query.SafetyMechanismQueryObject;
import cn.wolfcode.crm.service.ISafetyMechanismService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SafetyMechanismServiceImpl implements ISafetyMechanismService {
    @Autowired
    private SafetyMechanismMapper safetyMechanismMapper;

    public int deleteByPrimaryKey(Long id) {
        return safetyMechanismMapper.deleteByPrimaryKey(id);
    }

    public int insert(SafetyMechanism entity) {
        return safetyMechanismMapper.insert(entity);
    }

    public SafetyMechanism selectByPrimaryKey(Long id) {
        return safetyMechanismMapper.selectByPrimaryKey(id);
    }

    public List<SafetyMechanism> selectAll() {
        return safetyMechanismMapper.selectAll();
    }

    public int updateByPrimaryKey(SafetyMechanism entity) {
        return safetyMechanismMapper.updateByPrimaryKey(entity);
    }

    public PageResult query(SafetyMechanismQueryObject qo) {
        int totalCount = safetyMechanismMapper.queryForCount(qo);
        if (totalCount == 0) {
            return new PageResult();
        }
        List<SafetyMechanism> list = safetyMechanismMapper.queryForList(qo);
        return new PageResult(totalCount, list);
    }

    public int updateState(Long id) {
        return safetyMechanismMapper.updateState(id, SafetyMechanism.STATE_LOCK);
    }
<<<<<<< HEAD

    @Override
    public List<SafetyMechanism> listAll() {
        List<SafetyMechanism> safetyMechanisms = safetyMechanismMapper.selectAll();
        return safetyMechanisms;
    }
=======
>>>>>>> 524224bf820c6d6da01f752551ee21b728709493
}
